package operation;

import result.Score;
import result.ScoreList;

import java.util.Scanner;

public class ModifyOperation implements IOperation{
    @Override
    public void work(ScoreList scoreList) {
        System.out.println("修改学生成绩!!!");
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入要修改的学生姓名:");
        String name=sc.nextLine();
        System.out.println("请输入要修改的学生学号:");
        String studentID=sc.nextLine();
        System.out.println("请输入要修改的课程名称:");
        String courseName=sc.nextLine();
        int size=scoreList.getSize();
        for(int i=0;i<size;i++){
            Score score=scoreList.getScores(i);
            if(score.getName().equals(name)&&score.getStudentID().equals(studentID)&&score.getCourseName().equals(courseName)){
                System.out.println("请输入要修改的分数:");
                int score1=sc.nextInt();
                score.setScore(score1);
                System.out.println("修改成功！");
                return;
            }
        }
        System.out.println("没有该学生成绩，请重新输入！");
    }
}
